<?php if (!defined('ITPK')) exit('You can not directly access the file.');

/**
 * 标记操作类
 * @author 冬天的秘密
 * @link http://bbs.itpk.cn
 * @version 1.0
 */

class WebsystemPer extends WebDBConnection {

	/**
	 * 根据标记和Name获取存储的值
	 * @param string $mark
	 * @param string $name
	 * @param unknown $default_value
	 * @return unknown
	 */
	public function getValueByName($mark, $name, $default_value = null) {
		$meta = $this->db->executeQuery("SELECT value FROM web_system WHERE mark = '{$mark}' AND name = '{$name}' LIMIT 1", true);
		return $meta ? $meta['value'] : $default_value;
	}

	/**
	 * 根据标记获取所有的值
	 * @param string $mark
	 * @return array | boolean
	 */
	public function getMeByMark($mark) {
		return $this->db->executeQuery("SELECT * FROM web_system WHERE mark = '{$mark}'", true, true);
	}

	/**
	 * 保存标记的值
	 * @param string $mark
	 * @param string $name
	 * @param string $value
	 * @return boolean
	 */
	public function replaceSys($mark, $name, $value) {
		return $this->db->executeQuery("REPLACE INTO web_system(mark, name, value) VALUES('{$mark}', '{$name}', '{$value}')") > 0 ? true : false;
	}

}
?>